package cn.mcartoon.serviceImpl;
import cn.mcartoon.mapper.MmChapterBuyRecordMapper;
import cn.mcartoon.pojo.MmChapterBuyRecord;
import cn.mcartoon.service.MmChapterBuyRecordService;
import cn.mcartoon.dto.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.ArrayList;
import java.util.HashMap;
@Service
public class MmChapterBuyRecordServiceImpl implements MmChapterBuyRecordService {

    @Autowired
    private MmChapterBuyRecordMapper mmChapterBuyRecordMapper;

    public MmChapterBuyRecord getMmChapterBuyRecordById(Long id){
        return mmChapterBuyRecordMapper.getMmChapterBuyRecordById(id);
    }

    public List<MmChapterBuyRecord>	getMmChapterBuyRecordListByMap(Map<String,Object> param){
        return mmChapterBuyRecordMapper.getMmChapterBuyRecordListByMap(param);
    }

    public Integer getMmChapterBuyRecordCountByMap(Map<String,Object> param){
        return mmChapterBuyRecordMapper.getMmChapterBuyRecordCountByMap(param);
    }

    public Integer insertMmChapterBuyRecord(MmChapterBuyRecord mmChapterBuyRecord){
            return mmChapterBuyRecordMapper.insertMmChapterBuyRecord(mmChapterBuyRecord);
    }

    public Integer updateMmChapterBuyRecord(MmChapterBuyRecord mmChapterBuyRecord){
        return mmChapterBuyRecordMapper.updateMmChapterBuyRecord(mmChapterBuyRecord);
    }

    public Integer deleteMmChapterBuyRecordById(Long id){
        return mmChapterBuyRecordMapper.deleteMmChapterBuyRecordById(id);
    }

    public Integer batchDeleteMmChapterBuyRecord(String ids){
        Map<String,List<String>> param=new HashMap<String,List<String>>();
        String[] paramArrays=ids.split(",");
        List<String> idList=new ArrayList<String>();
            for (String temp:paramArrays){
                idList.add(temp);
            }
        param.put("ids",idList);
        return mmChapterBuyRecordMapper.batchDeleteMmChapterBuyRecord(param);
    }

    public Page<MmChapterBuyRecord> queryMmChapterBuyRecordPageByMap(Map<String,Object> param,Integer pageNo,Integer pageSize){
        Integer total = mmChapterBuyRecordMapper.getMmChapterBuyRecordCountByMap(param);
        Page page = new Page(pageNo, pageSize, total);
        param.put("beginPos", page.getBeginPos());
        param.put("pageSize", page.getPageSize());
        List<MmChapterBuyRecord> mmChapterBuyRecordList = mmChapterBuyRecordMapper.getMmChapterBuyRecordListByMap(param);
        page.setList(mmChapterBuyRecordList);
        return page;
     }


}
